
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/template/template.xhtml">

	<ui:define name="content">
		<h:form id="listaCliente">
			<br/>
			<p:commandButton actionListener="#{clienteMB.novo}"
				value="Novo"
				update=":editaCliente"
				oncomplete="salvaCliente.show()" />
			<br/>
			<br/>
			<p:dataTable value="#{clienteMB.listaClientes}" var="cliente">
				<p:column headerText="ID">#{cliente.id}</p:column>
				<p:column headerText="Nome">#{cliente.nome}</p:column>
				<p:column headerText="Endereço">#{cliente.endereco}</p:column>
				<p:column>
					<p:commandButton value="Excluir"
						actionListener="#{clienteMB.excluir}"
						update=":listaCliente">
						<f:setPropertyActionListener target="#{clienteMB.cliente}"
							value="#{cliente}"></f:setPropertyActionListener>
					</p:commandButton>
					<p:commandButton value="Editar" update=":editaCliente" oncomplete="salvaCliente.show()">
						<f:setPropertyActionListener target="#{clienteMB.cliente}"
							value="#{cliente}"></f:setPropertyActionListener>
					</p:commandButton>
				</p:column>

			</p:dataTable>
		</h:form>

		<p:dialog widgetVar="salvaCliente" modal="true">
			<h:form id="editaCliente">
				<h:panelGrid columns="2">
					<h:outputText value="Nome" />
					<p:inputText value="#{clienteMB.cliente.nome}"
						requiredMessage="Nome obrigatório" />

					<h:outputText value="Endereço" />
					<p:inputText value="#{clienteMB.cliente.endereco}"
						requiredMessage="Nome Obrigatório" />

					<p:commandButton actionListener="#{clienteMB.salvar}"
						oncomplete="salvaCliente.hide()" value="Salvar"
						update=":listaCliente" />
				</h:panelGrid>

			</h:form>
		</p:dialog>
	</ui:define>

</ui:composition>
</html>